package com.lovi.user.controller;

import com.lovi.param.CartListParam;
import com.lovi.param.PageParam;
import com.lovi.pojo.User;
import com.lovi.user.service.UserService;
import com.lovi.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class AdminUserController {
    @Autowired
    private UserService userService;

    @GetMapping("/test")
    String test(){
        return "hhhhhhh";
    }

    @PostMapping("/admin/list")
    R adminListPage(@RequestBody PageParam pageParam){
        return userService.listPage(pageParam);
    }

    @PostMapping("/admin/remove")
    R adminRemove(@RequestBody CartListParam cartListParam){
        return userService.removeUser(cartListParam.getUserId());
    }

    @PostMapping("/admin/update")
    R adminUpdate(@RequestBody User user){

        return userService.updateUser(user);
    }

    @PostMapping("/admin/save")
    R adminSave(@RequestBody User user){
        return userService.saveUser(user);
    }
}
